﻿using System;
using System.Diagnostics;
using System.Diagnostics.CodeAnalysis;

namespace Workbench.Shared
{
    [SuppressMessage("Microsoft.Design", "CA1063:ImplementIDisposableCorrectly")]
    public class TimeMeasure : IDisposable
    {
        DateTime Start;
        string Name;
        public TimeMeasure(string Name)
        {
            Start = DateTime.Now;
            this.Name = Name; 
        }
        int steps = 1;

        public void Step()
        {
            Debug.WriteLine(string.Format("{0} Step {1}: {2}", Name, steps, DateTime.Now - Start));
            steps++;
        }

        public void Step(string stepName)
        {
            Debug.WriteLine(string.Format("{0} Step {1} - {2}: {3}", Name, steps, stepName, DateTime.Now - Start));
            steps++;
        }

        [SuppressMessage("Microsoft.Design", "CA1063:ImplementIDisposableCorrectly")]
        public void Dispose()
        {
            Debug.WriteLine(string.Format("{0}: {1}", Name, DateTime.Now - Start));
        }
    }
}
